<?php 
 include_once dirname(__FILE__)."/config.php";
 class aa_complement_infos_principal{
		 protected $_resultrequest;
		 protected $_cnn;
		 protected $_id;
		 protected $_label;
		 protected $_id_lang;
		 public function get_name_table(){ return "aa_complement_infos";}
		 public function get_name_id(){ return "id";}
		 public function get_name_label(){ return "label";}
		 public function get_name_id_lang(){ return "id_lang";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_label($parametre){  $this->_label=$parametre;}	
		 public function set_id_lang($parametre){  $this->_id_lang=$parametre;}	
		 public function get_resultrequest(){ return $this->_resultrequest;}
		 public function get_id(){ return $this->_id;}
		 public function get_label(){ return $this->_label;}
		 public function get_id_lang(){ return $this->_id_lang;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 aa_complement_infos(
			label,
			id_lang)
 VALUES(
			'".$this->_label."',
			'".$this->_id_lang."')";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_label)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
label='".$this->_label."'";
}
if(!empty($this->_id_lang)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
id_lang='".$this->_id_lang."'";
}
$sql="UPDATE 
aa_complement_infos SET 
 ".$sql."
								WHERE 1=1  AND id ='".$this->_id."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
aa_complement_infos 
 
									WHERE 1=1  AND id ='".$this->_id."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
aa_complement_infos ";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		label,
		id_lang
 FROM 
 aa_complement_infos";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function countRowInTable($constraint="")
{

$sql=" SELECT 
  COUNT(*) AS total 
 FROM 
 aa_complement_infos ";
	$this->_resultrequest=$this->_cnn->query($sql);
$donnees_total=mysql_fetch_assoc($this->_resultrequest);
return $donnees_total['total'];
}
public function fetch_object(){
$row=mysql_fetch_object($this->_resultrequest);
 if($this->_resultrequest){
 if($row){
		$this->_id=$row->id;
		$this->_label=$row->label;
		$this->_id_lang=$row->id_lang;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>